<template>
  <div class="header-section">
    <!-- 右上角时间更新信息和全屏按钮 -->
    <div v-if="dataStatus.lastUpdate" class="data-status">
      <div class="fullscreen-btn" @click="toggleFullscreen">
        <i :class="isFullscreen ? 'el-icon-close' : 'el-icon-full-screen'"></i>
      </div>
    </div>

    <!-- 顶部标题区 -->
    <div class="header">
      <div class="title-section">
        <h1>汽车厂主轴监测平台</h1>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'HeaderSection',
  props: {
    dataStatus: {
      type: Object,
      required: true
    },
    isFullscreen: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    toggleFullscreen() {
      this.$emit('toggle-fullscreen');
    }
  }
}
</script>

<style lang="scss" scoped>
.header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: transparent;

  .title-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;

    h1 {
      margin-top: 15px;
      font-size: 35px;
      font-weight: 500;
      color: #fff;
      letter-spacing: 1px;
    }

    .tabs {
      display: flex;
      gap: 2px;
      justify-content: center;

      .tab {
        padding: 2px 12px;
        font-size: 12px;
        color: #fff;
        cursor: pointer;
        background: rgba(0, 60, 120, 0.5);
        border-radius: 10px;

        &.active {
          background: rgba(0, 120, 255, 0.3);
        }

        &:hover {
          background: rgba(0, 120, 255, 0.2);
        }
      }
    }
  }

  .status-legend {
    display: flex;
    gap: 15px;
    min-width: 180px;

    &.left {
      justify-content: flex-start;
    }

    &.right {
      justify-content: flex-end;
    }

    .legend-item {
      display: flex;
      align-items: center;
      font-size: 12px;
      color: #8f9bb3;
      white-space: nowrap;

      .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        margin-right: 5px;

        &.normal {
          background: #00ff00;
        }

        &.waiting {
          background: #ff9900;
        }

        &.warning {
          background: #ff0000;
        }

        &.offline {
          background: #666666;
        }
      }
    }
  }
}
</style>

<style lang="scss" scoped>
.header-section {
  position: relative;
}

.data-status {
  position: absolute;
  top: 10px;
  right: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 15px;
  color: #8f9bb3;
  font-size: 12px;

  .updating-dot {
    width: 8px;
    height: 8px;
    background: #52c41a;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
  }

  .fullscreen-btn {
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;

    &:hover {
      background: rgba(255, 255, 255, 0.2);
      transform: scale(1.1);
    }

    i {
      font-size: 16px;
      color: #fff;
    }
  }
}

.header {
  text-align: center;
  margin-bottom: 30px;

  .title-section {
    h1 {
      color: #fff;
      font-size: 28px;
      font-weight: 500;
      margin: 0;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
</style>
